<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>JS中批量产生对象</title>
    <script type="text/javascript">
        var Dog = function () {
            this.name = null;
            this.age = null;
            this.length = null;
            this.dogFriend = [];
            this.eat = function (food) {
                console.log(this.name + '正在吃' + food);
            }
            this.run = function (place) {
                console.log(this.name + '正在' + place + '跑步');
            }
        }

        var dog1 = new Dog();
        dog1.name = '小宝';
        dog1.age = 3;
        dog1.dogFriend = ['小虎', '皮球'];
        var dog2 = new Dog();
        dog2.name = '皮球';
        dog2.age = 3;
        dog2.dogFriend = ['小宝', '皮球'];
        console.log(dog1, dog2);

        // 带有参数的构造函数
        var Cat = function (name, age, length, catFriend) {
            this.name = name;
            this.age = age;
            this.length = length;
            this.catFriend = catFriend;
        }

        var cat1 = new Cat('橙橙', 2, 55, ['乐乐']);
        console.log(cat1);

    </script>
</head>
<body>

</body>
</html>